<template>
  <div class="commity">
    <!-- 渲染多个列表商品 -->
        <div class="title">热销</div>
        <div class="good" v-for="(item,index) in goodList[currentIndex].list" :key="index">
            <div class="good_img">
                <img :src="item.pic" alt="">
            </div>
            <div class="good_message">
                <div class="text">
                    <div class="name">{{item.name}}</div>
                    <div class="explain">{{item.intro}}</div>
                    <div class="yueshou"><span>月售{{item.yx}}份</span>&nbsp;<span>好评率{{item.hp}}%</span></div>
                </div>
                <div class="price">
                    <span>￥{{item.price}}</span>
                    <span>+</span>
                </div>
            </div>
        </div>
  </div>
</template>

<script>
export default {
    // props:{
    //     'goodList':{typeof:Array,default:[]},
    //     'currentIndex':{typeof:Number,default:0}
    // }
    // 通过props接收从父组件传来的值，该值是只读的(不能修改)
    props:['goodList','currentIndex'],
}
</script>

<style lang="scss" scoped>
    .commity{
        width: 75%;
        overflow: hidden;
    }
    .title{
        width: 100%;
        height: 20px;
        line-height: 20px;
        color: 14px;
    }
    .commity .good{
        display: flex;
        background: white;
        margin: 10px 0;
    }
    .commity .good .good_img{
        width: 80px;
        height: 80px;
        margin: 10px 10px 10px 0;
    }
    .commity .good .good_img img{
        width: 80px;
    }
    .commity .good .good_message{
        line-height: 20px;
        width: 100%;
    }
    .commity .good .good_message .name{
        font-weight: bold;
        font-size: 14px;
        margin-top: 5px;
    }
    .commity .good .good_message .explain{
        width: 90%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 12px;
        color: #666;
    }
    .commity .good .good_message .yueshou{
        font-size: 12px;
        color: #666;
    }
    .commity .good .good_message .price{
        width: 180px;
       display: flex;
       justify-content: space-between;
       margin-top: 10px;
    }
    .commity .good .good_message .price span:nth-child(1){
        color: red;
    } 
    .commity .good .good_message .price span:nth-child(2){
        width: 20px;
        height: 20px;
        color: white;
        background: rgb(9, 158, 217);
        border-radius: 50%;
        line-height: 20px;
        text-align: center;
    }
</style>
